home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Presentations / Presentations ’97 / Sessions ’97 / Moscaritolo's OT modem notes / OT⁄PPP Pref Format Notes < prev   
Encoding:
Text File  |  1997-06-27  |  12.9 KB  |  388 lines  |  [TEXT/R*ch]

  1. NOTE:: USE THE FOLLOWING INFORMATION AT YOUR OWN RISK!! 
  2. THIS IS NOT SUPPORTED BY DTS AND COULD (WILL PROBABLY) CHANGE IN THE FUTURE
  3.  
  4. /*******************************************************************************
  5. *    Configuration Format Notes
  6. *
  7. *    Client Configurations
  8. *    
  9. *    OT/PPP and OT/Remote Access client configurations store the information 
  10. *    necessary to place outgoing remote access calls. Configurations in OT/PPP
  11. *    Version 1.0 are stored in a file called "Remote Access Connections" in the
  12. *    "Remote Access" sub-folder of the Preferences folder. The type and creator
  13. *    of this file are defined below.
  14. *    
  15. *    A client configuration is a collection of resources of different types, all
  16. *    with the same resource ID. Multiple configurations can be stored in the
  17. *    config file, with the currently selected configuration specified by a
  18. *    meta-configuration resource (type 'ccfg', kRASelectedConfigType). This 
  19. *    scheme produces configurations compatible with the human interface
  20. *    infrastructure OT/PPP currently inherits from Open Transport 1.1 and 1.1.1.
  21. *    
  22. *    The client configuration resources are described below. Note that some of 
  23. *    the resources are optional, while others must be present for the
  24. *    configuration to be valid. 
  25. *
  26. *
  27. *    In addition to the resources associated with specific configurations, the
  28. *    config file may contain one or more "global" resource, such as the 'ccfg'
  29. *    mentioned above. These resources are also described below.
  30. *
  31. ********************************************************************************/
  32.  
  33.  
  34. #define kRASelectedConfigID            1            
  35.     // The ID for the global 'ccfg' resource 
  36.  
  37. #define kRAConfigFirstID            128            
  38.     // The starting ID for configuration resources
  39.     
  40. #define kRASelectedConfigType        'ccfg'        
  41.     // Contains:    SInt16
  42.     // Description:    ID of current selected configuration.
  43.     // Client:        required, global
  44.  
  45. #define kRAConfigNameType            'cnam'
  46.     // Contains:    SInt16, ignored.
  47.     // Description:    the resource name is the configuration's name.
  48.     // Client:        required, specific
  49.     
  50. #define kRAConfigTypeUserMode        'usmd'        
  51.     // Contains:    see below
  52.     // Description:    user mode info and admim password
  53.     // Client:        required, specific (but treated as global by PPP control panel)
  54.  
  55. type kRAConfigTypeUserMode
  56. {
  57.     unsigned longint;                    // version
  58.     unsigned longint;                    // userMode
  59.     pstring [255];                        // adminPassword
  60. };
  61.  
  62. #define kRAConfigTypeClientMisc        'cmsc'
  63.     // Contains:    see below
  64.     // Description:    miscellaneous config info
  65.     // Client:        required, specific
  66.  
  67. type kRAConfigTypeClientMisc
  68. {
  69.     unsigned longint;                    // version
  70.     unsigned longint;                    // isAutoConnect
  71. };
  72.  
  73. #define kRAConfigTypeConnect        'conn'
  74.     // Contains:    see below
  75.     // Description:    general connection information
  76.     // Client:        required, specific    
  77.  
  78. type kRAConfigTypeConnect
  79. {
  80.     unsigned longint;                    // version
  81.     unsigned longint;                    // type
  82.     unsigned longint;                    // isGuest
  83.     unsigned longint;                    // canInteract
  84.     unsigned longint;                    // showStatus
  85.     unsigned longint;                    // passwordSaved
  86.     unsigned longint;                    // flashConnectedIcon
  87.     unsigned longint;                    // issueConnectedReminders
  88.     longint;                            // reminderMinutes
  89.     unsigned longint;                    // connectManually
  90.     unsigned longint;                    // allowModemDataCompression
  91.     unsigned longint;                    // chatMode
  92.     unsigned longint;                    // serialProtocolMode
  93.     unsigned longint;                    // password *
  94.     unsigned longint;                    // userName *
  95.     unsigned longint;                    // addressLength
  96.     unsigned longint;                    // address *
  97.     pstring [64];                        // chatScriptName
  98.     unsigned longint;                    // chatScriptLength;
  99.     unsigned longint;                    // chatScript *
  100.     unsigned longint;                    // additional *
  101.     unsigned longint;                    // useSecurityModule
  102.     unsigned longint;                    // securitySignature
  103.     unsigned longint;                    // securityDataLength
  104.     unsigned longint;                    // securityData *
  105. };
  106.     
  107. #define kRAConfigTypeUser            'cusr'
  108.     // Contains:    variable length Pascal string
  109.     // Description:    the user login name, for RAConnect "user" field
  110.     // Client:        required, specific
  111.  
  112. type kRAConfigTypeUserMode
  113. {
  114.     unsigned longint;                    // version
  115.     unsigned longint;                    // userMode
  116.     pstring [255];                        // adminPassword
  117. };
  118.     
  119. #define kRAConfigTypePassword        'pass'
  120.     // Contains:    fixed length Pascal string (256)
  121.     // Description:    encrypted password, for RAConnect "password" field
  122.     // Client:        optional (required if passwordSaved == true), specific
  123.     
  124. #define kRAConfigTypeAddress        'cadr'
  125.     // Contains:    variable length string, no length byte
  126.     // Description:    string data for RAConnect "address" field, 
  127.     //                length determined by RAConnect::addressLength
  128.     // Client:        optional (required if addressLength > 0), specific 
  129.     
  130. #define kRAConfigTypeChat            'ccha'
  131.     // Contains:    variable length string data, no length byte
  132.     // Description:    string data for chat (connect) script, in
  133.     //                RAConnect "chatScript" field, length determined
  134.     //                by RAConnect::chatScriptLength
  135.     // Client:        optional (required if chatScriptLength > 0), specific
  136.     
  137. #define kRAConfigTypeDialing        'cdia'
  138.     // Contains:    see below
  139.     // Description:    dialing mode and redialing information
  140.     // Client:        required, specific
  141.  
  142. type kRAConfigTypeDialing
  143. {
  144.     unsigned longint;                    // version
  145.     unsigned longint;                    // type
  146.     unsigned longint;                    // additional *
  147.     unsigned longint;                    // dialMode
  148.     longint;                            // redialTries
  149.     unsigned longint;                    // redialDelay
  150.     unsigned longint;                    // addresses *
  151. };
  152.  
  153. #define kRAConfigTypeExtAddress        'cead'
  154.     // Contains:    RAAddress
  155.     // Description:    address (phone number) info for RADialing::addresses
  156.     // Client:        optional (required if RADialing::dialMode == 
  157.     //                kRADialModeRetryAlternates), specific
  158.         
  159. #define kRAConfigTypeLogOptions        'logo'
  160.     // Contains:    see below
  161.     // Description:    user log controls
  162.     // Client:        optional, specific
  163.  
  164. type kRAConfigTypeLogOptions
  165. {
  166.     unsigned longint;                // version
  167.     unsigned longint;                // type
  168.     unsigned longint;                // additional
  169.     unsigned longint;                // logLevel
  170.     fill long [4];                    // reserved[4], for future use.
  171. };
  172.     
  173. #define kRAConfigTypeClientLocks    'clks'
  174.     // Contains:    see below
  175.     // Description:    client configuration lock values
  176.     // Client:        required, specific
  177.  
  178. type kRAConfigTypeClientLocks
  179. {
  180.     unsigned longint;                    // version
  181.     unsigned longint;                    // name
  182.     unsigned longint;                    // password
  183.     unsigned longint;                    // number
  184.     unsigned longint;                    // errorCheck
  185.     unsigned longint;                    // headerCompress
  186.     unsigned longint;                    // termWindow
  187.     unsigned longint;                    // reminder
  188.     unsigned longint;                    // autoConn
  189.     unsigned longint;                    // redial
  190. };
  191.  
  192. #define kRAConfigTypeLCP            'lcp '
  193.     // Contains:    see below
  194.     // Description:    LCP parameters
  195.     // Client:        required, specific
  196.  
  197. type kRAConfigTypeLCP
  198. {
  199.     unsigned longint;                    // version
  200.     fill long [2];                        // reserved[2]
  201.     cstring [kRAMaxProviderNameSize];    // lowerLayerName
  202.     align long;                            // pad to 4-byte boundary
  203.     unsigned longint;                    // maxConfig
  204.     unsigned longint;                    // maxTerminate
  205.     unsigned longint;                    // maxFailureLocal
  206.     unsigned longint;                    // maxFailureRemote
  207.     unsigned longint;                    // timerPeriod
  208.     unsigned longint;                    // echoTriger
  209.     unsigned longint;                    // echoTimeout
  210.     unsigned longint;                    // echoRetries
  211.     unsigned longint;                    // compressionType
  212.     unsigned longint;                    // mruSize
  213.     unsigned longint;                    // upperMRULimit
  214.     unsigned longint;                    // lowerMRULimit
  215.     unsigned longint;                    // txACCMap
  216.     unsigned longint;                    // rcACCMap
  217. };
  218.  
  219. #define kRAConfigTypeIPCP            'ipcp'
  220.     // Contains:    see below
  221.     // Description:    IPCP parameters
  222.     // Client:        required, specific
  223.  
  224. type kRAConfigTypeIPCP
  225. {
  226.     unsigned longint;                // version
  227.     fill long [2];                    // reserved[2]
  228.     unsigned longint;                // maxConfig
  229.     unsigned longint;                // maxTerminate
  230.     unsigned longint;                // maxFailureLocal
  231.     unsigned longint;                // maxFailureRemote
  232.     unsigned longint;                // timerPeriod
  233.     unsigned longint;                // localIPAddress
  234.     unsigned longint;                // remoteIPAddress
  235.     unsigned longint;                // allowAddressNegotiation
  236.     unsigned longint;                // compressTCPHeaders
  237.     unsigned longint;                // idleTimerMilliseconds
  238. };
  239.  
  240. #define kRAConfigTypeTerm            'term'
  241.     // Contains:    see below
  242.     // Description:    terminal window parameters
  243.     // Client:        optional, global
  244.  
  245.     //
  246.     // Kind of characters that are drawn in the terminal
  247.     //
  248.     
  249.     typedef enum 
  250.     {
  251.         kTTYKindTyped        = 0,    // character typed on the keyboard and sent to the server
  252.         kTTYKindPrompted,            // unrequested character
  253.         kTTYKindEchoed,                // local echo character
  254.         kTTYMaxKindOfChar,            // limit for RAConfigTTY array
  255.         kTTYKindInitial        = -1    // Initial invalid value
  256.     } TTYKindOfChar;
  257.     
  258.     typedef struct
  259.     {
  260.         long        fVersion;
  261.         Boolean        fLocalEcho;
  262.         Boolean        fNonModal;
  263.         Boolean        fPowerUser;
  264.         Boolean        fQuitWhenPPPStarts;
  265.         Boolean        fDontAskVarStr;
  266.         Boolean        fNoVarStrReplace;
  267.         Boolean        fLFAfterCR;
  268.         Boolean        fAskToSaveOnQuit;
  269.         Rect        fWindowRect;
  270.         Style        fCharKindStyle[kTTYMaxKindOfChar + kTTYMaxKindOfChar % 2];    // 2 byte aligned
  271.         short        fFontSize;
  272.         Str255        fFontName;
  273.     } RAConfigTTY;
  274.  
  275.  
  276. /*******************************************************************************
  277. *    kRAConfigFormatVersion
  278. *
  279. *    Match the version in each resource read from the file with this
  280. *    constant to see if the code and the configurations file are compatible.
  281. *    High word represents major version, low word represents minor.
  282. ********************************************************************************/
  283.  
  284. #define kRAConfigFormatVersion        0x00010000
  285.  
  286.  
  287. /*******************************************************************************
  288. *    Miscellaneous constants used for configuration resources
  289. ********************************************************************************/
  290.  
  291. #define    kRADefaultRedialTries        1            // default number of times to redial
  292. #define kRADefaultRedialDelaySec    5            // default seconds between dial attempts
  293.  
  294. #define kRAConfigNoviceUser            1            // NOTE must be kept in sync with
  295. #define kRAConfigExpertUser            2            // values used by Peppermint framework
  296. #define kRAConfigAdminUser            3            // See CControlPanel.h (not rez-able)
  297.  
  298.  
  299. /*******************************************************************************
  300. * Info on the ARA/PPP username  and password.
  301. * The ARA/PPP password is stored using DES encryption with the
  302. * username as the key. There are many publically available
  303. * implementation of DES. You will need to find a DES
  304. * implementation (don't pay the bug bucks, just hunt around
  305. * the net, there are many to be found)  A good starting place
  306. * is the  crypto FTP archives at 
  307. * <http://www.cs.hut.fi/crypto/>
  308. * Only the first 8 characters of the user name affect the
  309. * 'pass' resource.  If the user name is greater than 8
  310. * character it does not matter what the characters are, they
  311. * have no effect.  The password, however, appears to have the
  312. * capability of using all 255 characters although I did not
  313. * actually test this.
  314. * The 'pass' resource is created as follows.  First the user
  315. * name is truncated to 8 characters.  Then the user name and
  316. * password are padded with zeros to be a fixed size buffer. 
  317. * The user name is 8 bytes zero padded and the password is 255
  318. * bytes zero padded.  The 8 byte user name is used as a key
  319. * but shifted one bit and munged as you described.  The 'pass'
  320. * resource we create will be 256 bytes long.  The first byte
  321. * is always zero.
  322. * Use the DES library  to encrypt 8 bytes at a time and then
  323. * append the encrypted bytes to the resource.  The resource
  324. * starts as off as one zeroed out byte.  Each pass through the
  325. * loop encrypts another 8 bytes using the same munged user
  326. * name for the key and the next 8 characters of the password
  327. * as the data until all 255 characters of the password are
  328. * used.
  329. * Since the first byte of the resource is the "always zero"
  330. * byte that adds up to 256.
  331. * If I were using the RSA version,  I would build an EncryptPassword
  332. * routine to look like:
  333. * void EncryptPassword(                        // encrypt a password using the user name as key
  334. *                     char *pUserName,        // the user name
  335. *                     char *pPasswordIn,        // the password
  336. *                     char *rPasswordOut)        // returns the encrypted password
  337. * {
  338. * // assumes null terminated strings for user name, and password in
  339. * // the password out buffer must be the (((password in buffer + 7) / 8) * 8)
  340. * // where the password in length includes the null termination char
  341. *     char        vKey[8];
  342. *     DES_CTX        vDESContext;
  343. *     struct{
  344. *             unsigned long hi;
  345. *             unsigned long lo;
  346. *             } shiftedKey;
  347. * // copy the password from the input to the output buffer (null padded)
  348. *     memset(rPasswordOut, 0, ((strlen(pPasswordIn) + 8) / 8) * 8);
  349. *     strcpy(rPasswordOut, pPasswordIn);
  350. * // make the key (null padded)
  351. *     memset(vKey, 0, 8);
  352. *     strncpy(vKey, pUserName, 8);
  353. * //each 32 bits word of the key must be shifted left by 1 bit before calling DESEncryptInit.
  354. *     memcpy(&shiftedKey, vKey, 8);
  355. *     shiftedKey.hi =shiftedKey.hi << 1;
  356. *     shiftedKey.lo =shiftedKey.lo << 1;
  357. *     memcpy(vKey, &shiftedKey, 8);
  358. * // initialize DES encryption
  359. *     memset(&vDESContext, 0, sizeof(vDESContext));
  360. *     DESEncryptInit(&vDESContext, (unsigned char*) vKey);
  361. * // encrypt the password
  362. *     DES(     (POINTER) &vDESContext, 
  363. *             (unsigned char*) rPasswordOut, 
  364. *             (unsigned char*) rPasswordOut);
  365. *     return;
  366. * }
  367. ********************************************************************************/
  368.